#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;

int n, m, p;
int a[N];
int mx[N << 2], mn[N << 2];
int ans;
int f(int p, int l, int r, int mxr) {  // 左区间
  if (l == r) return l + max(mx[p], mxr);
  int mid = (l + r) >> 1;
  if (mxr >= mx[p << 1 | 1])
    return min(mid + 1 + mxr, f(p << 1, l, mid, mxr));
  else
    return min(mn[p], f(p << 1 | 1, mid + 1, r, mxr));
}
void pushup(int p, int l, int r) {
  mx[p] = max(mx[p << 1], mx[p << 1 | 1]);
  int mid = (l + r) >> 1;
  mn[p] = f(p << 1, l, mid, mx[p << 1 | 1]);
}
void build(int p, int l, int r) {
  if (l == r) {
    mx[p] = a[l] - l;
    mn[p] = a[l];
    return;
  }
  int mid = (l + r) >> 1;
  build(p << 1, l, mid);
  build(p << 1 | 1, mid + 1, r);
  pushup(p, l, r);
}
void update(int x, int v, int p, int l, int r) {
  if (l == r) {
    mx[p] = v - l;
    mn[p] = v;
    return;
  }
  int mid = (l + r) >> 1;
  if (x <= mid)
    update(x, v, p << 1, l, mid);
  else
    update(x, v, p << 1 | 1, mid + 1, r);
  pushup(p, l, r);
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m >> p;
  rep(i, 1, n) cin >> a[i];
  rep(i, 1, n) a[i + n] = a[i];
  build(1, 1, n * 2);
  ans = mn[1] + n - 1;
  cout << ans << endl;
  while (m--) {
    int x, y;
    cin >> x >> y;
    if (p) x ^= ans, y ^= ans;
    update(x, y, 1, 1, n * 2);
    update(x + n, y, 1, 1, n * 2);
    ans = mn[1] + n - 1;
    cout << ans << endl;
  }
  return 0;
}